//
//  Controller11.swift
//  Swift30Days
//
//  Created by licheng ke on 2017/3/7.
//  Copyright © 2017年 licheng ke. All rights reserved.
//

import UIKit

//ClearTableViewCell
class Controller11: UIViewController,UITableViewDataSource {

    let datas = ["Read 3 article on Medium", "Cleanup bedroom", "Go for a run", "Hit the gym", "Build another swift project", "Movement training", "Fix the layout problem of a client project", "Write the experience of #30daysSwift", "Inbox Zero", "Booking the ticket to Chengdu", "Test the Adobe Project Comet", "Hop on a call to mom"]
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        configUI();
    }

    
    func configUI(){
        let tableView = UITableView(frame: view.bounds, style: .plain)
        view.addSubview(tableView);
        tableView.dataSource = self;
        tableView.tableFooterView = UIView();
        tableView.separatorStyle = .none;
        tableView.backgroundColor = .black;
        tableView.register(GradientCell.classForCoder(), forCellReuseIdentifier: "aaa")
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return datas.count;
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "aaa", for: indexPath);
        cell.backgroundColor = colorforIndex(indexPath.row);
        cell.textLabel?.text = datas[indexPath.row];
        return cell;
    }
    
    func colorforIndex(_ index: Int) -> UIColor {
        let itemCount = datas.count - 1
        let color = (CGFloat(index) / CGFloat(itemCount)) * 0.6
        return UIColor(red: 1.0, green: color, blue: 0.0, alpha: 1.0)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
